<?php
include("Coneccion.php");
$link=conectarse();
$link2=conectarse();
if(isset($HTTP_POST_VARS["id"]) && isset($HTTP_POST_VARS["nick"]) && isset($HTTP_POST_VARS["comentario"])){ 
	if($HTTP_POST_VARS["comentario"] != "") { 
		if($HTTP_POST_VARS["nick"] == ""){ 
			$nickNuevo = "anonimo"; 
		}else{ 
			$nickNuevo = $HTTP_POST_VARS["nick"]; 
		} 
		$idNoticia = $HTTP_POST_VARS["id"]; 
		$comentarioNoticia = $HTTP_POST_VARS["comentario"]; 
		mysql_query("INSERT INTO comentarios (cod_noticia,nick,comentario) VALUES ('$idNoticia','$nickNuevo','$comentarioNoticia');",$link); 		
		echo "<SCRIPT LANGUAGE='javascript'>alert('Comentario enviado con exito');</SCRIPT>"; 
	}else{ 
		echo "<SCRIPT LANGUAGE='javascript'>alert('Debe introducir un comentario');</SCRIPT>"; 
	} 
} 
?>

<HTML><HEAD>
<TITLE>Alberto Ravell</TITLE>
<style type="text/css">
<!--
.Estilo2 {color: #000000}
.Estilo1 {
	color: #CC0000;
	font-weight: bold;
	font-size: 26px;
}
.Estilo3 {color: #CC0000}
-->
</style>
<BODY text=#000000 vLink=#ff0000 aLink=#ff0000 link=#000000 bgColor=#ffffff 
topMargin=0 marginheight="0">
<style type="text/css">
ul {
	list-style: none;
	padding: 0;
	margin: 0;
}
/* Para las letras*/
#nav a { 
	font-weight:  bold;
	color: #FFFFFF; /*red;*/
}

#nav a {
	text-decoration: none;
}
/*Letras de la lista*/
#nav li li a {
	display: block;
	font-weight: normal;
	color: #FFFFFF; /* #060;*/
	padding: 0.2em 10px;
}

#nav li li a:hover {
	padding: 0.2em 5px;
	border: 5px solid #000000; /*#7d6340;*/
	border-width: 0 5px;
}

li {
	float: left;
	position: relative;
	width: 10em;
	text-align: center;
	cursor: default;
	background-color: #FF0000; /* white;*/
	/*border: 1px solid #7d6340;
	border-width: 1px 0;*/
}

li#first {
	border-left-width: 1em;
}

li#last {
	border-right-width: 1em;
}

li ul {
	display: none;
	position: absolute;
	top: 100%;
	left: 0;

	font-weight: normal;
	background: url(images/ddbg3.gif) bottom left no-repeat;
	padding: 0.5em 0 1em 0;
	border-right: solid 1px #7d6340;
}

li>ul {
	top: auto;
	left: auto;
}
/* formato de la Lista*/
li li {
	display: block;
	float: none;
	background-color: #FF0000; /* transparent;*/
	border: 0;
}

li:hover ul, li.over ul {
	display: block;
}

hr {
	display: none;
}

</style>
<TABLE height="100%" cellSpacing=3 cellPadding=0 width=549 align=center bgColor=#ffffff border=0>
  <TBODY>
  <TR>
    <TD vAlign=top width=543 bgColor=#ff0000 height="100%">
      <TABLE height="100%" cellSpacing=1 width=541 align=center border=0>
        <TBODY>
        <TR>
          <TD vAlign=top bgColor=#ffffff height="100%" width="537">           
		   <DIV align=center>              <BR>
              <DIV align=left></DIV>
              <DIV align=left style="width: 459; height:"100%"">
			  <?php				
				$result=mysql_query("SELECT *,DATE_FORMAT(Fecha_Publicacion, '%d-%m-%Y') as Fecha FROM noticia WHERE Publicado ='0' AND ((Fin_publicacion >=  CURDATE() and Inicio_Publicacion <=CURDATE()) or Fin_publicacion = '0000-00-00') AND Nivel_acceso =0 ORDER BY Cod_noticia DESC",$link);
				while($row = mysql_fetch_array ($result))
				{
					$titulo= $row["Titulo"];
					$texto= $row["Texto"];
					$autor = $row["Pseudonimo"];
					$fecha = $row["Fecha"];
					$codnot = $row["Cod_noticia"];
					echo "<span class='Estilo1'>$titulo</span><br><span class='Estilo3'>";	
					if(strcmp($autor,""))
						echo "Escrito por $autor | ";
					echo "Publicado el $fecha </span><br>";																								
					echo "<br>";
					echo "$texto";
					echo "<br>";
			?>
		 	<FORM NAME="miFormu" ACTION="comentar.php" METHOD="post"> 
			<INPUT TYPE="hidden" NAME="id" VALUE="<?php echo "$codnot"; ?>"> 			
			<INPUT TYPE="submit" CLASS="boton" VALUE="Comentar"> 
			</FORM>		
			<?php
					$resultComen = mysql_query("SELECT * FROM comentarios WHERE cod_noticia='$codnot' ORDER BY id ASC;",$link2); 					
					$row2 = mysql_fetch_array($resultComen);				
					$cmt= $row2["comentario"];									
					if(strcmp($cmt,"")){
			?>
			<CENTER> 
			<TABLE CELLSPACING=1 CELLPADDING=1 WIDTH=450 BORDER=0 STYLE="border:1px solid black"> 
			<TR> 
				<TD BGCOLOR="#FAFAFA"> 
				<CENTER> 
					<SPAN STYLE="font-size:11px;font-family:Tahoma;color:black;font-weight:bold"> 
						.Comentarios De Los Usuarios.					</SPAN> 
				</CENTER>				</TD> 
			</TR> 
			<TR> 
				<TD HEIGHT=1 BGCOLOR=black> </TD> 
			</TR> 
			<TR> 
				<TD BGCOLOR="#FEFEFE"> 
					<SPAN STYLE="font-size:11px;font-family:Tahoma;color:black;"> 
			<?php
				$resultComen2 = mysql_query("SELECT * FROM comentarios WHERE cod_noticia='$codnot' ORDER BY id ASC",$link); 
				while($rowComen2 = mysql_fetch_array($resultComen2)){ 
				$nick = $rowComen2["nick"];
				$cmt2 = $rowComen2["comentario"];
			?> 
			<FONT COLOR=RED> <B><?php echo "$nick"; ?></B> </FONT> : 
			<?php echo "$cmt2"; ?> <BR> 
			<? } 
			?> 
		</SPAN>		</TD> 
		</TR> 
		</TABLE> 
		</CENTER> 																						
			<?php	
			} echo "<DIV align=center><FONT color=#ff0000>_______________________________________________________</FONT> </DIV><br>";}
			?>
              </DIV>
              </DIV></TD></TR></TBODY></TABLE></TD>
</TR></TBODY></TABLE>
<p align="center" style="margin-top: 7; margin-bottom: 0">
        <font face="Arial" size="1">Copyright 2011 Consejo Comunal Alberto Ravell        </font>

</BODY></HTML>